﻿using EasyBuyShop.Models;
using EasyBuyShop.Utils;

namespace EasyBuyShop.DAL
{
    public class ShopDal : BaseDal
    {
        public Shop GetShopById(long Id) {
            try
            {
                using (var db = this.GetDb(BaseDal.ConnStr))
                {
                    return db.Queryable<Shop>().First(r => r.Id == Id);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Fatal(ex.Message);
                return null;
            }
        }

        public List<Shop> GetShops(List<long> shopIds)
        {
            try
            {
                using (var db = this.GetDb(BaseDal.ConnStr))
                {
                    return db.Queryable<Shop>().Where(r => shopIds.Contains(r.Id)).ToList();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Fatal(ex.Message);
                return new List<Shop>();
            }
        }
    }
}
